﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using Luna;

namespace TextDataExtractor.DEML {
	class TestDEML {
		
		public void testLoadFactory() {
			DemlRegistry r = new DemlRegistry();
			r.loadPatterns("mfsa-deml.xml");

			string input = System.IO.File.ReadAllText("mfsa.html");

			testPattern(r.findPattern("MFSA"), input);
		}

		public void testPattern(AbstractPattern pattern, string input) {
			Debug.WriteLine("Pattern: " + pattern.Name);
			if (pattern.match(input) > 0) {
				//Debug.WriteLine(pattern.MatchedText);
				//Debug.WriteLine("----------------");
				
				//foreach (AbstractPattern p in pattern.getMatchedPatterns()) {
				//    Debug.WriteLine("pattern: {0}, Start={1}, End={2}", p.Name, p.StartIndex, p.EndIndex);
				//    Debug.WriteLine("---------------------------------");
				//    Debug.WriteLine(p.MatchedText);
				//    Debug.WriteLine("---------------------------------");
				//    Debug.WriteLine("");
				//}

				Debug.WriteLine(pattern.getMatchedPatternName(0));
				ExecutionContext app = new ExecutionContext(null, "Test");
				pattern.performExtraction(app);
			}
			else
				Debug.WriteLine("Not matched");
		}
	}
}
